<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../../css/weui.min.css" />
		<link rel="stylesheet" type="text/css" href="../../css/jquery-weui.min.css" />
		<link rel="stylesheet" type="text/css" href="../../css/index.css" />
		<link rel="stylesheet" type="text/css" href="../../css/information.css" />
		<link rel="stylesheet" type="text/css" href="https://at.alicdn.com/t/font_546019_o8qxm6fupb0ggb9.css" />
		<title>资讯</title>
		<script src="../../js/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/jquery-weui.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/baseConfig.js" type="text/javascript" charset="utf-8"></script>
		<!--<script src="../../js/muSwiper.js" type="text/javascript" charset="utf-8"></script>-->
	</head>
	<body>
		<!--<div id="header">
			<div class="header-title" style="position: fixed;top: 0;">
				<img src="../../img/left.png" class="left" />
				<span>资讯</span>
			</div>
		</div>-->

		<div class="muSwiper-wrap" style="margin-top: 0;">
			<div class="muSwiper-list">
				<ul class="muSwiper-title">
					<!--<li class="active muSwiper-slide">全部</li>
					<li class="muSwiper-slide">政策</li>
					<li class="muSwiper-slide">宏观市场</li>
					<li class="muSwiper-slide">废钢</li>
					<li class="muSwiper-slide">铜</li>
					<li class="muSwiper-slide">铝</li>
					<li class="muSwiper-slide">拆解物</li>-->
				</ul>
			</div>
			<div class="tlg">

			</div>
			<div class="muSwiper-content">
				<ul class="muSwiper-box">
					<!--<li class="active muSwiper-slide">
						<div class="swiperList">
							<div class="fl-left">
								<img src="../../img/squarePhoto.png" />
							</div>
							<div class="fl-right">
								<h4>我是标题</h4>
								<p>
									<span class="from">来源:网优资讯</span>
									<span class="time">2017/12/08</span>
								</p>
							</div>
						</div>
					</li>-->
				</ul>
			</div>
		</div>

		<div id="footer">
			<div class="weui-tabbar" style="position: fixed;">
				<a href="../demand/demand.html" data-info='1' class="weui-tabbar__item ">
					<div class="weui-tabbar__icon">
						<img src="../../img/foot1.png" class="show" />
					</div>
					<p class="weui-tabbar__label">需求</p>
				</a>
				<a href="information.html" data-info='2' class="weui-tabbar__item weui-bar__item--on">
					<div class="weui-tabbar__icon">
						<img src="../../img/footgreen2.png" class="show" />
					</div>
					<p class="weui-tabbar__label">资讯</p>
				</a>
				<a href="../order/orderList.html" data-info='3' class="weui-tabbar__item ">
					<div class="weui-tabbar__icon">
						<img src="../../img/foot3.png" class="show" />
					</div>
					<p class="weui-tabbar__label">订单</p>
				</a>
				<a href="../mine/mine.html" data-info='4' class="weui-tabbar__item ">
					<div class="weui-tabbar__icon">
						<img src="../../img/foot4.png" class="show" />
					</div>
					<p class="weui-tabbar__label">我的</p>
				</a>
			</div>
		</div>
	</body>
	<script type="text/javascript">
		$(document).ready(function() {
			baseConfig.historyBack()
			$.showLoading("加载中...");
//			muSwiper({
//				wrap: ".muSwiper-title",
//				items: ".muSwiper-slide",
//				num: 5
//			}, {
//				wrap: ".muSwiper-box",
//				items: ".muSwiper-slide"
//			})
//$(".muSwiper-title").css("width",7*20+"%")
//$(".muSwiper-title .muSwiper-slide").css("width",100/7+"%")
			$.ajax({
					type: "get",
					url: baseConfig.localHttp+"weChatApi/fgclient/getNewsTypeList",
					async: false,
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					success: function(data) {
						$.hideLoading();
//						console.log(data)
						if(data.code==100){
							var $li = ""
//							$(".muSwiper-box").html()  //一进来置空
							var content = data.content		
							checkType(content[0].value)  //获取第一个
							for(var i=0;i<content.length;i++){
								$li += "<li class='muSwiper-slide' type="+content[i].value+">"+content[i].name+"</li>"
							}
							$('.muSwiper-title').append($li)
							$(".muSwiper-title").css("width",content.length*50+"%")
							$(".muSwiper-title .muSwiper-slide").css("width",100/content.length+"%")
							$(".muSwiper-title .muSwiper-slide").eq(0).addClass("active")
							for(var j=0;j<$('.muSwiper-title li').length;j++){
								$('.muSwiper-title li').eq(j).on("click",function(){
									$(this).addClass("active").siblings().removeClass("active");
									var index = $(this).index()
									checkType(content[index].value)
								})
							}
						}else{
							$.toptip(data.content, 1200, 'error');
						}			
					},
					error:function(){
						$.hideLoading();
						$.toast("请求失败", "cancel");
					}
				})
		function checkType(value){
			$.showLoading("加载中...");
			$(".muSwiper-box").html("")
			$.ajax({
					type: "get",
					url: baseConfig.localHttp+"weChatApi/fgclient/getNewsInfo",
					async: false,
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					},
					data:{
						type:value
					},
					success: function(data) {
						$.hideLoading();
//						console.log(data)
						var $li2 = ""
						if(data.code==100){
							var content = data.content
//							console.log(content.length)
							for(var i=0;i<content.length;i++){
								$li2 += "<li class='active muSwiper-slide' data-id="+content[i].id+">"
								$li2 +=		"<div class='swiperList'>"
								$li2 +=			"<div class='fl-left'>"
								$li2 +=				"<img src='../../img/squarePhoto.png' />"
								$li2 +=			"</div>"
								$li2 +=			"<div class='fl-right'>"
								$li2 +=				"<h4>"+content[i].title+"</h4>"			
								$li2 +=			"<p><span class='from'>来源:"+content[i].from+"</span>"
								$li2 +=		"<span class='time'>"+content[i].createDate.slice(0,11)+"</span></p></div></div></li>"																			
						}
							$(".muSwiper-box").html($li2)
							for(var j=0;j<$(".muSwiper-box li").length;j++){
								$(".muSwiper-box li").eq(j).on("click",function(){
									var id = $(this).attr("data-id")
									location.href = "informationDetails.html?id="+id
								})
							}
						}else{
							$.toptip(data.content, 1200, 'error');
						}			
					},
					error:function(){
						$.hideLoading();
						$.toast("请求失败", "cancel");
					}
				})
			}
		})
	</script>

</html>